﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mail.Model;
using Core.DAL.EF;
using Core.Mvc.Framework;
using Core.Mvc.Framework.Action;

namespace AutoEmailSender.Controllers
{
    public class EmailController : Controller
    {
        public ActionResult GetUsers()
        {
            UserDAO dao = new UserDAO();
            return View("SendByUser", "BindingUsers", dao.FindAll());
        }

        public ActionResult GetCategoriesByUserId(int? id)
        {
            CategoryDAO dao = new CategoryDAO();
            List<EmailCategory> ret = new List<EmailCategory>();
            new UserCategoryDAO().FindByCategoryId(id).ForEach(u =>
               {
                   ret.Add(dao.Find(u.CatedoryId));
               });
            return View("SendByUser", "BindingCategories", ret);
        }
    }
}
